<% products_active =  %w[products external_categories taxons taxonomies option_types option_values properties stock_items stock_transfers].include?(controller_name) || request.path.include?('products') %>
<% if can?(:manage, Spree::Product) %>
  <%= nav_item(Spree.t(:products), spree.admin_products_path, icon: 'package', active: products_active) %>

  <%# Submenu for expanded sidebar (only shown when active) %>
  <ul class="nav-submenu <% unless products_active %>d-none<% end %>">
    <% if can?(:manage, Spree::StockItem) || can?(:manage, Spree::StockTransfer) %>
      <%= nav_item(Spree.t(:stock), spree.admin_stock_items_path, active: %w[stock_items stock_transfers].include?(controller_name)) %>
    <% end %>
    <% if can?(:manage, Spree::Taxonomy) && can?(:manage, Spree::Taxon) %>
      <%= nav_item(Spree.t(:taxonomies), spree.admin_taxonomies_path) %>
    <% end %>
    <% if can?(:manage, Spree::OptionType) %>
      <%= nav_item(Spree.t(:options), spree.admin_option_types_path, active: %w[option_types option_values].include?(controller_name)) %>
    <% end %>
    <% if can?(:manage, Spree::Property) && Spree::Config[:product_properties_enabled] %>
      <%= nav_item(Spree.t(:properties), spree.admin_properties_path) %>
    <% end %>

    <%= render_admin_partials(:store_products_nav_partials) %>
  </ul>

  <%# Submenu dropdown for collapsed sidebar (always rendered, shown on hover) %>
  <ul class="nav-submenu-dropdown d-none dropdown-container">
    <%= nav_item(Spree.t(:products), spree.admin_products_path) %>

    <% if can?(:manage, Spree::StockItem) || can?(:manage, Spree::StockTransfer) %>
      <%= nav_item(Spree.t(:stock), spree.admin_stock_items_path) %>
    <% end %>
    <% if can?(:manage, Spree::Taxonomy) && can?(:manage, Spree::Taxon) %>
      <%= nav_item(Spree.t(:taxonomies), spree.admin_taxonomies_path) %>
    <% end %>
    <% if can?(:manage, Spree::OptionType) %>
      <%= nav_item(Spree.t(:options), spree.admin_option_types_path) %>
    <% end %>
    <% if can?(:manage, Spree::Property) && Spree::Config[:product_properties_enabled] %>
      <%= nav_item(Spree.t(:properties), spree.admin_properties_path) %>
    <% end %>

    <%= render_admin_partials(:store_products_nav_partials) %>
  </ul>
<% end %>
